<div class="content gzt_main">
    <div class="layui-card gzt_header layui-row">
        <div class="item layui-col-md6 selected">
            <i class="icon"></i>
            <span>上传工资表</span>
            <div class="line"></div>
        </div>
        <div class="item layui-col-md6 active">
            <i class="icon"></i>
            <span>核对工资表</span>
            <div class="line"></div>
        </div>
        <div class="item2">
            <i class="icon"></i>
            <span>发放工资表</span>
        </div>
    </div>
    <div class="layui-tab gzt_main2">
        <ul class="layui-tab-title">
            <li{:$status == 1 ? ' class="layui-this"' : ''}><a href="{:url('manage/payslip_check', ['id' => $id, 'status' => 1])}">发放记录</a></li>
            <li{:$status == 2 ? ' class="layui-this"' : ''}><a href="{:url('manage/payslip_check', ['id' => $id, 'status' => 2])}">失败记录</a></li>
        </ul>
        <div class="layui-tab-content layui-card">
            <div class="search_box">
                <form id="search-form" class="layui-form layui-clear" role="form" data-toggle="validator" method="GET" action="{:url('manage/payslip_check', ['id' => $id])}">
                    <div class="search_input">
                        <input type="text" name="keywords" value="{$keywords|htmlentities}" placeholder="请输入员工姓名、手机号搜索" class="layui-input">
                        <button type="submit" class="search_icon iconfont icon-sousuo"></button>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">选择部门</label>
                        <div class="layui-input-inline">
                            <select name="department_id" lay-filter="department_id">
                                <option value="">请选择部门</option>
                                {if $departments}
                                {foreach $departments as $did => $dname}
                                <option value="{$did}" {if $did==$department_id}selected{/if}>{$dname}</option>
                                {/foreach}
                                {/if}
                            </select>
                        </div>
                    </div>
                    <input type="hidden" name="page" value="{$lists.current_page}">
                    <div class="but">
                        <a class="del_but del_all">删除</a>
                    </div>
                </form>
            </div>
            <div class="layui-tab-item layui-show">
                <div class="table">
                    <table class="layui-table" lay-skin="line" lay-even="">
                        <thead>
                        <tr>
                            <th><div class="checkbox"><i class="iconfont icon-gou"></i></div></th>
                            <th>姓名</th>
                            <th>部门</th>
                            <th>账号</th>
                            <th>实发工资</th>
                            {if $columns}
                            {foreach $columns as $name}
                            <th>{$name}</th>
                            {/foreach}
                            {/if}
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {if $lists.data}
                        {foreach $lists.data as $item}
                        <tr>
                            <td><div class="checkbox" data-id="{$item.id}"><i class="iconfont icon-gou"></i></div></td>
                            <td><div class="w_80">{$item.nickname|default='<span class="yg_no">无此员工</span>'}</div></td>
                            <td><div class="w_100">{$item.department_name|default='-'}</div></td>
                            <td><div class="w_100">{$item.username|default='-'}</div></td>
                            <td><div class="text_box"><input type="text" data-id="{$item.id}" data-name="payslip_total" class="layui-input field" value="{$item.payslip_total}"></div></td>
                            {if $columns}
                            {foreach $columns as $name}
                            <td><div class="text_box"><input type="text" data-id="{$item.id}" data-name="payslip_json[{$name}]" class="layui-input field" value="{$item[$name]}"></div></td>
                            {/foreach}
                            {/if}
                            <td class="but_box">
                                {if $item.user_id}
                                <a class="cancel_but" data-id="{$item.id}">取消匹配</a>
                                {else}
                                <a class="pipei_but" data-id="{$item.id}" data-amount="{$item.payslip_total}">手动匹配</a>
                                {/if} ｜
                                <a class="del_but" data-id="{$item.id}">删除</a>
                            </td>
                        </tr>
                        {/foreach}
                        {/if}
                        </tbody>
                    </table>
                </div>
                <div id="laypage" data-total="{$lists.total}" data-per_page="{$lists.per_page}" data-current_page="{$lists.current_page}"></div>
            </div>
        </div>
    </div>
    <div class="add_but_box">
        <a href="javascript:;" class="layui-btn layui-btn-primary back_but" data-url="{:url('manage/payslip_add')}">上一步</a>
        <a href="{:url('manage/payslip_confirm', ['id' => $id])}" class="layui-btn layui-btn-determine">下一步</a>
    </div>
</div>

<div class="pop pipei_pop">
    <div class="pop_content">
        <form id="bind-form" class="layui-form layui-clear" role="form" data-toggle="validator" method="POST" action="{:url('manage/payslip_check')}">
            <div class="layui-card-header">手动匹配</div>
            <div class="close iconfont icon-guanbi"></div>
            <div class="layui-card-body">
                <div class="pipei_item">实发工资：<span class="amount"></span><span class="yg_no">无此员工</span></div>
                <div class="fxlx_item layui-clear">
                    <input type="text" name="nickname" placeholder="请输入匹配员工姓名…" class="layui-input">
                    <a class="layui-btn search_but">搜索</a>
                </div>
                <div class="pipei_list"></div>
            </div>
            <div class="pop_but">
                <input type="hidden" name="id" value="">
                <input type="hidden" name="type" value="user_bind">
                <a class="layui-btn layui-btn-primary">取消</a>
                <button type="submit" class="layui-btn layui-btn-determine">确定</button>
            </div>
        </form>
    </div>
</div>

<script type="text/html" id="user_tpl">
    <% for(i = 0; i < data.length; i ++) { %>
    <% if (i == 0) { %><input type="hidden" name="user_id" value="<%=data[i]['id']%>"><% } %>
    <div class="pipei_item2<% if (i == 0) { %> active<% } %>" data-id="<%=data[i]['id']%>">
        <div class="head_img"><img src="<%=data[i]['avatar']%>" alt=""/></div>
        <h3><%=data[i]['nickname']%></h3>
        <p><%=data[i]['department_name']%></p>
    </div>
    <% } %>
</script>